The IDL_Integer class contains static methods that are available for integers. In addition, because IDL_Integer is a subclass of IDL_Number, all of the IDL_Number and IDL_Variable methods are also available.
The IDL_Integer::BitLength method returns the number of bits in the scalar or array, ignoring any leading zero bits.
num = [0, 1, 2, 7, 16385]
PRINT, num.BitLength( )
IDL prints:
0 1 2 3 15
Result = var.BitLength( )
A scalar byte or a byte array of the same dimensions as the variable. Each element in the Result will contain the number of bits in the corresponding value.
None.
None.
The IDL_Integer::BitGet method returns a byte array of the variable.
Print the 3rd bit value of each element of an array:
num = INDGEN(8)
PRINT, num.BitGet( 3 )
IDL prints:
0 0 0 0 1 1 1 1
Result = var.BitGet( Location )
A byte array containing the bit value of each element of the variable.
A scalar integer designating the location of the requested bit.
None.
The IDL_Integer::BitSet method returns the variable after setting the bit or bit values.
Print the value of a variable after setting the bits on each element:
num = [0, 0, 0, 0]
PRINT, num.BitSet([1, 2, 3, 4])
IDL prints:
1 2 4 8
Result = var.BitSet( Location [, /CLEAR] [, /FLIP])
The scalar or array of values of the variable after their bits have been set.
The location of which bit to set.
Set this keyword to clear the bits specified by Location.
Set this keyword to flip the bits specified by Location.
The IDL_Integer::BitShift method returns a scalar or array after a bit shift operation.
Print the value of a number after shifting the bit:
num = [1, 10, 100]
; [ShiftRightOnePosition, ShiftLeftFivePositions, NoShift]
PRINT, num.BitShift( [-1, 5, 0] )
PRINT, num.BitShift( [-1, 5, 0], /CIRCULAR )
IDL prints:
0 320 100
-32768 320 100
Result = var.BitShift( Direction [, /CIRCULAR] )
The value of the scalar or array after the bit shift operation.
A scalar or array containing the number of bit positions and the direction of the shift.
If the element of Direction is positive, the related element of the array is left-shifted that many bit positions, with 0 bits filling vacated positions.
If the element of Direction is negative, the related element of the array is right-shifted that many bit positions, with 0 bits filling vacated positions.
Set this keyword to shift the number circularly (i.e., shifting right a value of 1 would return -32768).
The IDL_Integer::ToASCII method returns a string containing the ASCII value of a number.
Print the ASCII value of a number:
num = [72, 101, 108, 108, 111]
PRINT, num.ToASCII( )
IDL prints:
Hello
Result = var.ToASCII( )
A scalar string or string array containing the ASCII values.
None.
None.
The IDL_Integer::ToBinary method returns a string containing the binary representation of the number.
Print the hex value of a number:
num = [24601, 1728, 79]
PRINT, num.ToBinary( )
IDL prints:
110000000011001 11011000000 1001111
Result = var.ToBinary( )
A scalar string or string array containing the binary representation.
None.
None.
The IDL_Integer::ToHex method returns a string containing the hex value of the number.
Print the hex value of a number:
num = [24601, 1728, 79]
PRINT, num.ToHex( )
IDL prints:
6019 6C0 4F
Result = var.ToHex( )
A scalar string or string array containing the hex values.
None.
None.
The IDL_Integer::ToOctal method returns a string containing the octal value of the number.
Print the octal value of a number:
num = [24601, 1728, 79]
PRINT, num.ToOctal( )
IDL prints:
60031 3300 117
Result = var.ToOctal( )
A scalar string or string array containing the octal values.
None.
None.
|
8.4 |
Introduced |
Static Methods and Attributes, Variable Attributes, IDL_Number, IDL_Pointer, IDL_String, IDL_Variable